package com.medical.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.medical.model.entity.DeptScore;
import org.apache.ibatis.annotations.*;

/**
 * @author TISNIW
 * @version 1.0
 * @desc
 */


@Mapper
public interface DeptScoreMapper extends BaseMapper<DeptScore> {

    /**
     * 根据部门id查询部门评分
     * @param deptId 部门id
     * @return 部门评分
     */
    @Select("select * from dept_score where dept_id = #{deptId}")
    DeptScore getByDeptId(Long deptId);
    @Insert("insert into dept_score (dept_id, communication_score, teamwork_score, productivity_score, innovation_score, leadership_score) " +
            "values (#{deptId}, #{communicationScore}, #{teamworkScore}, #{productivityScore}, #{innovationScore}, #{leadershipScore})")
    DeptScore saveScore(Long deptId, DeptScore deptScore);
    // DeptScoreMapper.java
    @Update({"<script>",
            "UPDATE dept_score SET",
            "communication_score = #{communicationScore},",
            "teamwork_score = #{teamworkScore},",
            "productivity_score = #{productivityScore},",
            "innovation_score = #{innovationScore},",
            "leadership_score = #{leadershipScore}",
            "WHERE dept_id = #{deptId}",
            "</script>"})
    int updateByDeptId(@Param("deptId") Long deptId, @Param("communicationScore") Integer communicationScore,
                       @Param("teamworkScore") Integer teamworkScore,
                       @Param("productivityScore") Integer productivityScore,
                       @Param("innovationScore") Integer innovationScore,
                       @Param("leadershipScore") Integer leadershipScore);

    @Select("SELECT * FROM dept_score WHERE dept_id = #{deptId}")
    DeptScore selectByDeptId(Long deptId);
}